<?php

/**
 * This is the model class for table "kegiatan".
 *
 * The followings are the available columns in table 'kegiatan':
 * @property integer $id
 * @property string $nama
 * @property string $tanggalMulai
 * @property string $tanggalSelesai
 * @property string $waktu
 * @property string $tempat
 * @property string $deskripsi
 * @property string $evaluasi
 * @property string $proposal
 * @property integer $user_id
 * @property string $foto
 * @property string $galeri
 * @property integer $kepengurusan_id
 * @property integer $statusKeg_id
 *
 * The followings are the available model relations:
 * @property Kepengurusan $kepengurusan
 * @property User $user
 * @property Statuskeg $statusKeg
 */
class Kegiatan extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Kegiatan the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'kegiatan';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('nama, tanggalMulai, tempat, deskripsi, user_id, kepengurusan_id, statusKeg_id', 'required'),
			array('user_id, kepengurusan_id, statusKeg_id', 'numerical', 'integerOnly'=>true),
			array('nama, tempat', 'length', 'max'=>255),
			array('waktu, proposal, foto', 'length', 'max'=>100),
			array('deskripsi, evaluasi', 'length', 'max'=>1000),
			array('galeri', 'length', 'max'=>225),
			array('tanggalSelesai', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, nama, tanggalMulai, tanggalSelesai, waktu, tempat, deskripsi, evaluasi, proposal, user_id, foto, galeri, kepengurusan_id, statusKeg_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'kepengurusan' => array(self::BELONGS_TO, 'Kepengurusan', 'kepengurusan_id'),
			'user' => array(self::BELONGS_TO, 'User', 'user_id'),
			'statusKeg' => array(self::BELONGS_TO, 'Statuskeg', 'statusKeg_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'nama' => 'Nama',
			'tanggalMulai' => 'Tanggal Mulai',
			'tanggalSelesai' => 'Tanggal Selesai',
			'waktu' => 'Waktu',
			'tempat' => 'Tempat',
			'deskripsi' => 'Deskripsi',
			'evaluasi' => 'Evaluasi',
			'proposal' => 'Proposal',
			'user_id' => 'User',
			'foto' => 'Foto',
			'galeri' => 'Galeri',
			'kepengurusan_id' => 'Kepengurusan',
			'statusKeg_id' => 'Status Keg',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('nama',$this->nama,true);
		$criteria->compare('tanggalMulai',$this->tanggalMulai,true);
		$criteria->compare('tanggalSelesai',$this->tanggalSelesai,true);
		$criteria->compare('waktu',$this->waktu,true);
		$criteria->compare('tempat',$this->tempat,true);
		$criteria->compare('deskripsi',$this->deskripsi,true);
		$criteria->compare('evaluasi',$this->evaluasi,true);
		$criteria->compare('proposal',$this->proposal,true);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('foto',$this->foto,true);
		$criteria->compare('galeri',$this->galeri,true);
		$criteria->compare('kepengurusan_id',$this->kepengurusan_id);
		$criteria->compare('statusKeg_id',$this->statusKeg_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}